package com.xmy.cultivate.mapper;

import com.xmy.cultivate.entity.RoleAdmin;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author min
 * @since 2022-09-09
 */
public interface RoleAdminMapper extends BaseMapper<RoleAdmin> {

    @Select("select role_id from role_admin where admin_id = #{adminId}")
    public abstract List<Long> getRoleIdListForAdminId(@Param("adminId") Long adminId);

    @Select("select `name` from role where id in (select role_id from role_admin where admin_id =  #{adminId})")
    public abstract List<String> getAdminRoleNameList(@Param("adminId") Long adminId);

    /**
     * 获取角色编号
     * @return
     */
    @Select("SELECT admin_id FROM role_admin")
    Integer getAdminIdInteger();

    @Select("select admin_id from role_admin where role_id = #{roleId}")
    public abstract List<Long> getAdminIdListByRoleAdmin(@Param("roleId") Long roleId);
}
